package ss.pku.meeting.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import ss.pku.meeting.entities.ApplicationRecord;
import ss.pku.meeting.entities.Message;

import java.util.List;

@Mapper
public interface MessageMapper {
    @Select({
            "select count(id) ",
            "from message where to_id=#{deptId} and status = 0"
    })
    int selectUnreadCount(int deptId);

    List<Message> selectByCondition(Message message);

    @Update({
        "update message",
            "set status = 1",
            "where id=#{id}"
    })
    int update(int id);

    @Insert({
            "insert into message(from_id,to_id,content,status) ",
            "values(#{fromId}, #{toId}, #{content} ,0)"
    })
    int insert(int fromId, int toId, String content);
}
